<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script type="text/javascript" src="../js/jquery-3.0.0.js"></script>

    <link rel="stylesheet" type="text/css" href="../layui/css/layui.css" media="all"/>
    <script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="../css/customer.css"/>

    <style type="text/css">
        /* html, */
        body {
            width: 100%;
            height: 100%;

            overflow: overlay;
        }

        .layui-container {
            width: 100%;
            height: 100%;

        }

        .logo-title {
            text-align: left;
            letter-spacing: 2px;
            padding: 10px 0;
        }

        .logo-title h1 {
            font-size: 25px;
            font-weight: bold;
        }

        .layui-form {
            background-color: #fff;
            border: 1px solid #fff;
            border-radius: 3px;
            /*padding: 0px 20px;*/
            box-sizing: border-box;
        }

        .layui-form .layui-form-item label {
            width: 100px;
        }

        .layui-form .layui-form-item input {
            line-height: 36px;
        }

        .add_btn {
            float: right;
            right: 20px;
        }
    </style>
</head>
<body>

<form class="layui-form" action="" layui-filter="cu_form">
    <div class="layui-form-item">

        <div style=" float: left;  width: 300px; height: 40px;"><img
                style="width: 35px;height: 35px; margin-left: 30px; "
                src="">
            <span class="text"
                  style="margin: 10px; line-height: 40px; font-size: 18px;  color: #000000;  font-weight: 700; ">我的关注</span>
        </div>


        <!--<div class="layui-inline ad_inline ">-->
        <!--<label class="layui-form-label">场景</label>-->
        <!--<div class="layui-input-inline  addin">-->
        <!--<select name="interest" lay-verify="required" lay-filter="co_select">-->
        <!--<option value="全部合同">全部合同</option>-->
        <!--<option value="待审批">待审批</option>-->
        <!--</select>-->
        <!--</div>-->
        <!--</div>-->

    </div>
</form>


<script src="../layui/layui.js" charset="utf-8"></script>
<table class="layui-hide" id="tb" lay-filter="cu_demo" style="margin-top: 50px;"></table>
<script type="text/html" id="barDemo">
    <!--<a class="layui-btn layui-btn-xs" lay-event="pass" id="pass">关注</a>-->
    <a class="layui-btn layui-btn-danger  layui-btn-xs" lay-event="no_pass" id="no_pass">取消关注</a>
</script>

<script type="text/javascript">
    $(function () {
        layui.use(["laypage", "table", "form"], function () {
            var laypage = layui.laypage;
            var page, limit;
            var $ = layui.jquery;
            var form = layui.form
            var table = layui.table;
            var element = layui.element;

            table.render({
                elem: '#tb',
                url: '../focus/findByUserid',
                toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
                defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                height: 750,
                title: '合同表',
                cols: [[
                    {
                        type: 'checkbox',
                        fixed: 'left'
                    },
                    {
                        field: 'u_name',
                        title: '姓名',
                        width: 300,
                        sort: true,
                        fixed: true
                    },
                    {
                        field: 'u_phone',
                        title: '手机',
                        width: 300,
                        sort: true

                    }, {
                        field: 'u_sex',
                        title: '性别',
                        width: 300
                    }, {
                        field: 'u_department',
                        title: '部门',
                        width: 300
                    }, {
                        field: 'u_job',
                        title: '岗位',
                        width: 300
                    },
                    {
                        fixed: 'right',
                        title: '操作',
                        minWidth: 100,
                        align: 'center',
                        toolbar: '#barDemo'
                    }
                ]
                ],
                where: {
                    userid: sessionStorage.getItem("userid")
                },
                // data: [{
                // 	"id": 1,
                // 	"co_name": "xxx合同",
                // 	"co_number": "18718762534",
                // 	"co_custname": "xxx公司",
                // 	"co_sign_time": "2020-10-11",
                // 	"co_money": "230000.00",
                // 	"co_start_time": "2020-11-11",
                // 	"co_end_time": "2021-11-11",
                // 	"co_cust_sign_name": "李四",
                // 	"co_us_name": "我方签约人"
                //
                // }],
                page: true,
                id: 'testReload'
            });


            //监听表格操作
            table.on('tool(cu_demo)', function (obj) {
                var data = obj.data;
                var layEvent = obj.event;
                var tr = obj.tr;
                console.log(layEvent)


                if (layEvent === 'no_pass') { //编辑
                    $.ajax({
                        url: '../focus/deleteFocus',
                        type: 'get',
                        data: {
                            'fo_be_id': data.id,
                            'fo_u_id': sessionStorage.getItem("userid")
                        },
                        success: function (suc) {
                            if (suc == 'success') {


                                window.location.reload();
                                // table.render("testReload",{})
                            } else {

                            }
                        }
                    });

                }
            });


            //4.下拉选择框的监听
            form.on('select(co_select)', function (data) {
                //console.log(data.elem); //得到select原始DOM对象
                //console.log(data.othis); //得到美化后的DOM对象
                console.log(data.value); //得到被选中的值
                var co_status = data.value;
                if (co_status == '全部合同') {
                    table.reload('testReload', {
                        url: '../contract/findAll',
                        //methods:"post"
                        page: {
                            curr: 1 //条件查询从第一页开始，否则从当前页面开始
                        }
                    });
                } else {
                    // alert(co_status);
                    table.reload('testReload', {
                        url: '../contract/findByStatus',
                        //methods:"post"
                        where: {
                            co_status: co_status //设置需要传递的参数

                        },
                        page: {
                            curr: 1 //条件查询从第一页开始，否则从当前页面开始
                        }
                    });
                }
            })
        })
    })
</script>

<script type="text/javascript" src="../js/jquery.min.js"></script>

</body>
</html>
